<!DOCTYPE html>
<html  lang="zh">
<head>
    <!-- hexo-inject:begin --><!-- hexo-inject:end --><meta charset="utf-8" />

<meta name="generator" content="Hexo 3.9.0" />

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />

<title>人工智能2-操纵行为 - 游戏人生</title>


    <meta name="description" content="AI">
<meta name="keywords" content="学习">
<meta property="og:type" content="article">
<meta property="og:title" content="人工智能2-操纵行为">
<meta property="og:url" content="http://cloundgame.gitee.io/mystudy/2020/07/22/人工智能2-操纵行为/index.html">
<meta property="og:site_name" content="游戏人生">
<meta property="og:description" content="AI">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="http://cloundgame.gitee.io/mystudy/images/og_image.png">
<meta property="og:updated_time" content="2020-07-22T10:17:41.779Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="人工智能2-操纵行为">
<meta name="twitter:description" content="AI">
<meta name="twitter:image" content="http://cloundgame.gitee.io/mystudy/images/og_image.png">







<link rel="icon" href="/mystudy/images/favicon.svg">


<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.7.2/css/bulma.css">
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/font-awesome/5.9.0/css/all.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Ubuntu:400,600|Source+Code+Pro">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@9.12.0/styles/atom-one-dark.css">


    
    
    
    <style>body>.footer,body>.navbar,body>.section{opacity:0}</style>
    

    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightgallery@1.6.8/dist/css/lightgallery.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/css/justifiedGallery.min.css">
    

    
    

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.css">


    
    
    
    

<link rel="stylesheet" href="/mystudy/css/back-to-top.css">


    
    

    
    
    
    

    
    
<link rel="stylesheet" href="/mystudy/css/progressbar.css">
<script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>

    
    
    
        <script async="" src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    

    


<link rel="stylesheet" href="/mystudy/css/style.css"><!-- hexo-inject:begin --><!-- hexo-inject:end -->
</head>
<body class="is-3-column">
    <!-- hexo-inject:begin --><!-- hexo-inject:end --><nav class="navbar navbar-main">
    <div class="container">
        <div class="navbar-brand is-flex-center">
            <a class="navbar-item navbar-logo" href="/mystudy/">
            
                <img src="/mystudy/images/logo.svg" alt="人工智能2-操纵行为" height="28">
            
            </a>
        </div>
        <div class="navbar-menu">
            
            <div class="navbar-start">
                
                <a class="navbar-item"
                href="/mystudy/">主页</a>
                
                <a class="navbar-item"
                href="/mystudy/archives">日志</a>
                
                <a class="navbar-item"
                href="/mystudy/categories">分类</a>
                
                <a class="navbar-item"
                href="/mystudy/">关于</a>
                
            </div>
            
            <div class="navbar-end">
                
                    
                    
                    <a class="navbar-item" target="_blank" title="Download on GitHub" href="https://github.com/koliy/koliy.github.io">
                        
                        <i class="fab fa-github"></i>
                        
                    </a>
                    
                
                
                <a class="navbar-item is-hidden-tablet catalogue" title="目录" href="javascript:;">
                    <i class="fas fa-list-ul"></i>
                </a>
                
                
                <a class="navbar-item search" title="搜索" href="javascript:;">
                    <i class="fas fa-search"></i>
                </a>
                
            </div>
        </div>
    </div>
</nav>
    
    <section class="section">
        <div class="container">
            <div class="columns">
                <div class="column is-8-tablet is-8-desktop is-6-widescreen has-order-2 column-main"><div class="card">
    
    <div class="card-content article ">
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2020-07-22T08:39:33.000Z">2020-07-22</time>
                
                <div class="level-item">
                <a class="has-link-grey -link" href="/mystudy/categories/AI/">AI</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    
                    
                    12 分钟 读完 (大约 1844 个字)
                </span>
                
                
                <span class="level-item has-text-grey" id="busuanzi_container_page_pv">
                    <i class="far fa-eye"></i>
                    <span id="busuanzi_value_page_pv">0</span>次访问
                </span>
                
            </div>
        </div>
        
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                人工智能2-操纵行为
            
        </h1>
        <div class="content">
            <h2 id="操纵行为"><a href="#操纵行为" class="headerlink" title="操纵行为"></a><strong>操纵行为</strong></h2><p>初学unity3D时，常常会运到这样的情况：设计的角色在行进过程中运到障碍物而无法避开，它不停地与障碍物碰撞，与障碍物相对滑动，一直到滑出障碍物为止；有时，可能会一直卡在那里，不停地原地踏步.</p>
<a id="more"></a>
<ul>
<li>如果角色需要从A移动到B，但被路上的一堵墙挡住了去路，那么它会做出相应的反应，调整自己的行为，而不是机械地贴在墙上播放行走动画而不前进。</li>
<li>如果一个角色发现了比它强大得多的敌人正在靠近，那么该立即逃走，而这个更强大的敌人也会自行去追逐逃走的角色。在这个逃走的过程中，追逐者会预测逃跑者的未来位置，并前往预测的方向拦截，而不是傻乎乎地一直跟着逃跑者的后面。</li>
<li>在一个足球游戏中，玩家希望正在试图接球的球员会预测球的位置，向预测的方向奔跑，或是在接近球的时候减速准备接球，而不是保持常速，在球到达时忽然停住。</li>
<li>对于一个需要巡逻的角色，玩家可能希望它能再场景中随机徘徊游荡，而不希望它沿着几个固定点巡逻。</li>
<li>如果一个角色需要穿越火力而前往某个目标点完成任务，玩家显然希望它能再途中尽量避开危险，安全到达目标点，而不是大摇大摆地穿过火力线而过早被击毙。</li>
<li>对于多个单位组成的小队，例如一群飞鸟，玩家不希望它们像仪仗队那样机械地保持队形且路线完全一致的运动，而是希望它们的运动既有一致性，但同时还呈现出某些个性，看上去更新真实生动.</li>
</ul>
<p><strong>操纵行为:是指操作控制角色，让它们能以模拟真实的方式在游戏世界中移动，它的工作方式是通过产生一定大小和方向的操控力，使角色以某种方式运动</strong></p>
<p><strong>操控行为可以认为是包括一组基本的行为的集合。</strong></p>
<ul>
<li>使角色靠近或离开目标的”Seek”,”FLee”行为</li>
<li>当角色接近目标时减速的”Arrival”行为</li>
<li>角色避开障碍物的行为</li>
</ul>
<p>基本行为中的每个行为都产生相应的操控力，将这些操控力以一定的方式组合起来，就能得到更复杂的行为，从而实现更为高级的目标。</p>
<p><strong>对于组成小队或群体的多个AI角色</strong></p>
<ul>
<li>与其它相邻角色保持一定距离的行为</li>
<li>与其它相邻角色保持一致朝向的行为</li>
<li>靠近其它相邻角色的行为</li>
</ul>
<table>
<thead>
<tr>
<th>行为名称</th>
<th>中文</th>
<th>解释</th>
</tr>
</thead>
<tbody><tr>
<td>Seek</td>
<td>靠近</td>
<td>使角色靠近目标</td>
</tr>
<tr>
<td>Flee</td>
<td>离开</td>
<td>使角色离开目标</td>
</tr>
<tr>
<td>Arrival</td>
<td>抵达</td>
<td>当角色接近目标时减速</td>
</tr>
<tr>
<td>Pursuit</td>
<td>追逐</td>
<td>捕猎者追逐猎物</td>
</tr>
<tr>
<td>Evade</td>
<td>逃避</td>
<td>猎物逃离捕猎者</td>
</tr>
<tr>
<td>Wander</td>
<td>随机徘徊</td>
<td>随机徘徊</td>
</tr>
<tr>
<td>PathFollowing</td>
<td>路径跟随</td>
<td>使角色沿着某条预定路径移动</td>
</tr>
<tr>
<td>ObstacleAvoidance</td>
<td>避开障碍</td>
<td>避开障碍物</td>
</tr>
<tr>
<td>GroupBehavior</td>
<td>组行为</td>
<td>多角色成组的操控行为</td>
</tr>
<tr>
<td>Radar</td>
<td>雷达</td>
<td>探测周围相邻角色位置</td>
</tr>
<tr>
<td>Separation</td>
<td>分离</td>
<td>与群中邻居保持适当距离</td>
</tr>
<tr>
<td>Alignment</td>
<td>队列</td>
<td>与群中邻居保持朝向一致</td>
</tr>
<tr>
<td>Cohesion</td>
<td>聚集</td>
<td>成群聚集在一起</td>
</tr>
</tbody></table>
<h2 id="主要基类"><a href="#主要基类" class="headerlink" title="主要基类"></a><strong>主要基类</strong></h2><p>本节内容位于AI模型中运动层。</p>
<h4 id="将AI角色抽象为一个质点-Vehicle类"><a href="#将AI角色抽象为一个质点-Vehicle类" class="headerlink" title="将AI角色抽象为一个质点-Vehicle类"></a><strong>将AI角色抽象为一个质点-Vehicle类</strong></h4><p>首先对AI角色做出抽象，假设它为一个交通工具(Vehicle),泛指马匹，飞机，汽车，动物，人物等。<br>在AI架构模型中，把对象抽象为一个质点，它包含了位置(position),质量(mass),速度(velocity)等信息，而速度随着所施加力的变化而变化。由于速度意味着是实际物理实体，施加在其上的力和能达到的速度都是有限制的，因此需要最大力和最高速度，同时还要包含一个朝向(orientation).</p>
<p><strong>综上，这个交通工具的位置计算方法是:</strong></p>
<ul>
<li><strong>确定每一帧的当前操控力(最大不超过max_force)</strong></li>
<li><strong>除以交通工具的质量mass，可以确定一个加速度</strong></li>
<li><strong>将这个加速度与原来的速度相加，得到新的速度</strong></li>
<li><strong>根据速度和这帧流逝的时间，计算出位置的变化</strong></li>
<li><strong>与原来位置相加，得到交通工具的新位置</strong></li>
</ul>
<figure class="highlight javascript hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">steering_force = Mathf.min(steering_force,max_force)</span><br><span class="line">acceleration = steering_force/ mass</span><br><span class="line">velocity = Mathf.min(velocity + acceleration * deltaT,max_speed)</span><br><span class="line">position = position + velocity * deltaT</span><br></pre></td></tr></table></figure>

<figure class="highlight javascript hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br></pre></td><td class="code"><pre><span class="line">using System.Collections;</span><br><span class="line">using System.Collections.Generic;</span><br><span class="line">using UnityEngine;</span><br><span class="line"></span><br><span class="line"><span class="hljs-comment">/// &lt;summary&gt;</span></span><br><span class="line"><span class="hljs-comment">/// 交通工具类，所有可一定的游戏AI角色都由此派生</span></span><br><span class="line"><span class="hljs-comment">/// &lt;/summary&gt;</span></span><br><span class="line">public class Vehicle : MonoBehaviour &#123;</span><br><span class="line"></span><br><span class="line">    <span class="hljs-comment">//这个AI角色包含的所有操控行为列表</span></span><br><span class="line">    private Steering[] steerings;</span><br><span class="line">    public float maxSpeed = <span class="hljs-number">10</span>;</span><br><span class="line">    public float maxForce = <span class="hljs-number">100</span>;</span><br><span class="line">    <span class="hljs-comment">//最大速度的平方，预先算出并存储，节省资源</span></span><br><span class="line">    protected float sqrMaxSpeed;</span><br><span class="line">    <span class="hljs-comment">//质量</span></span><br><span class="line">    public float mass = <span class="hljs-number">1</span>;</span><br><span class="line">    <span class="hljs-comment">//速度</span></span><br><span class="line">    public Vector3 velocity;</span><br><span class="line">    <span class="hljs-comment">//控制转向时的速度</span></span><br><span class="line">    public float damping = <span class="hljs-number">0.9</span>f;</span><br><span class="line">    <span class="hljs-comment">//操控力的计算间隔时间，避免每帧刷新</span></span><br><span class="line">    public float computeInterval = <span class="hljs-number">0.2</span>f;</span><br><span class="line">    <span class="hljs-comment">//是否在2D平面上，忽略y值的不同</span></span><br><span class="line">    public bool isPlanar = <span class="hljs-literal">true</span>;</span><br><span class="line">    <span class="hljs-comment">//计算得到的操控力</span></span><br><span class="line">    private Vector3 steeringForce;</span><br><span class="line">    <span class="hljs-comment">//加速度</span></span><br><span class="line">    protected Vector3 acceleration;</span><br><span class="line">    <span class="hljs-comment">//计时器</span></span><br><span class="line">    private float timer;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">	<span class="hljs-comment">// Use this for initialization</span></span><br><span class="line">	<span class="hljs-keyword">void</span> Start () &#123;</span><br><span class="line">        steeringForce = Vector3.zero;</span><br><span class="line">        sqrMaxSpeed = maxSpeed * maxSpeed;</span><br><span class="line">        timer = <span class="hljs-number">0</span>;</span><br><span class="line">        <span class="hljs-comment">//获取所有操控行为列表</span></span><br><span class="line">        steerings = GetComponents&lt;Steering&gt;();</span><br><span class="line"></span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	<span class="hljs-comment">// Update is called once per frame</span></span><br><span class="line">	<span class="hljs-keyword">void</span> Update () &#123;</span><br><span class="line">        timer += Time.deltaTime;</span><br><span class="line">        steeringForce = Vector3.zero;</span><br><span class="line"></span><br><span class="line">        <span class="hljs-keyword">if</span>(timer &gt; computeInterval)</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="hljs-comment">//将操控行为列表中的所有操控行为对应的操控力进行权重求和</span></span><br><span class="line">            foreach(<span class="hljs-keyword">var</span> s <span class="hljs-keyword">in</span> steerings)</span><br><span class="line">            &#123;</span><br><span class="line">                <span class="hljs-keyword">if</span> (s.enabled) steeringForce += s.Force() * s.weight;</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">            steeringForce = Vector3.ClampMagnitude(steeringForce, maxForce);</span><br><span class="line">            <span class="hljs-comment">//力除以质量，求出加速度</span></span><br><span class="line">            acceleration = steeringForce / mass;</span><br><span class="line">            timer = <span class="hljs-number">0</span>;</span><br><span class="line">        &#125;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="各种操控行为的基类-Vehicle类"><a href="#各种操控行为的基类-Vehicle类" class="headerlink" title="各种操控行为的基类-Vehicle类"></a><strong>各种操控行为的基类-Vehicle类</strong></h4><p>所有操控行为的基类，包含操控行为共有的变量和方法，操控AI角色的寻找，逃跑，等都由此派生。</p>
<figure class="highlight javascript hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">public class Steering : MonoBehaviour &#123;</span><br><span class="line">    <span class="hljs-comment">//表示每个操控力的权重</span></span><br><span class="line">    public float weight = <span class="hljs-number">1</span>;</span><br><span class="line"></span><br><span class="line">    public virtual Vector3 Force()</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="hljs-keyword">return</span> Vector3.zero;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="控制AI角色移动-AILocomotion"><a href="#控制AI角色移动-AILocomotion" class="headerlink" title="控制AI角色移动-AILocomotion"></a><strong>控制AI角色移动-AILocomotion</strong></h4><p>AILocomotion是Vehicle的派生类，它能真正控制AI角色的一定，包括计算每次移动的距离，播放动画等。</p>
<figure class="highlight javascript hljs"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br></pre></td><td class="code"><pre><span class="line">using System.Collections;</span><br><span class="line">using System.Collections.Generic;</span><br><span class="line">using UnityEngine;</span><br><span class="line"></span><br><span class="line">public class AILocomotion : Vehicle &#123;</span><br><span class="line"></span><br><span class="line">    private Rigidbody theRigidbody;</span><br><span class="line">    <span class="hljs-comment">//每次移动距离</span></span><br><span class="line">    private Vector3 moveDistance;</span><br><span class="line"></span><br><span class="line">	<span class="hljs-comment">// Use this for initialization</span></span><br><span class="line">	<span class="hljs-keyword">void</span> Start () &#123;</span><br><span class="line">        theRigidbody = GetComponent&lt;Rigidbody&gt;();</span><br><span class="line">        moveDistance = Vector3.zero;</span><br><span class="line">        base.Start();</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">    <span class="hljs-comment">//物理相关操纵在fixed中更新</span></span><br><span class="line">    <span class="hljs-keyword">void</span> FixedUpdate()</span><br><span class="line">    &#123;</span><br><span class="line">        velocity += acceleration * Time.fixedDeltaTime;</span><br><span class="line">        <span class="hljs-keyword">if</span> (velocity.sqrMagnitude &gt; sqrMaxSpeed) velocity = velocity.normalized * maxSpeed;</span><br><span class="line"></span><br><span class="line">        moveDistance = velocity * Time.fixedDeltaTime;</span><br><span class="line">        <span class="hljs-comment">//如果为2D平面</span></span><br><span class="line">        <span class="hljs-keyword">if</span> (isPlanar)</span><br><span class="line">        &#123;</span><br><span class="line">            velocity.y = <span class="hljs-number">0</span>;</span><br><span class="line">            moveDistance.y = <span class="hljs-number">0</span>;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="hljs-keyword">if</span>(theRigidbody == <span class="hljs-literal">null</span> || theRigidbody.isKinematic)</span><br><span class="line">        &#123;</span><br><span class="line">            transform.position += moveDistance;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="hljs-keyword">else</span></span><br><span class="line">        &#123;</span><br><span class="line">            theRigidbody.MovePosition(theRigidbody.position + moveDistance);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="hljs-comment">//防抖动</span></span><br><span class="line">        <span class="hljs-keyword">if</span>(velocity.sqrMagnitude &gt; <span class="hljs-number">0.00001</span>)</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="hljs-comment">//通过当前朝向与速度方向的插值，计算新的朝向,角色转向，逐渐朝向受力方向</span></span><br><span class="line">            Vector3 newForward = Vector3.Slerp(transform.forward, velocity, damping * Time.deltaTime);</span><br><span class="line">            <span class="hljs-keyword">if</span> (isPlanar) newForward.y = <span class="hljs-number">0</span>;</span><br><span class="line">            <span class="hljs-comment">//将向前的方向设置为新的朝向</span></span><br><span class="line">            transform.forward = newForward;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="hljs-comment">//播放动画</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>


        </div>
        
        <div class="level is-size-7 is-uppercase">
            <div class="level-start">
                <div class="level-item">
                    <span class="is-size-6 has-text-grey has-mr-7">#</span>
                    <a class="has-link-grey -link" href="/mystudy/tags/学习/">学习</a>
                </div>
            </div>
        </div>
        
        

        
        <div class="social-share"></div>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js@1.0.16/dist/css/share.min.css">
<script src="https://cdn.jsdelivr.net/npm/social-share.js@1.0.16/dist/js/social-share.min.js"></script>
        
    </div>
</div>





<div class="card card-transparent">
    <div class="level post-navigation is-flex-wrap is-mobile">
        
        <div class="level-start">
            <a class="level level-item has-link-grey  article-nav-prev" href="/mystudy/2020/07/22/人工智能3-靠近和离开/">
                <i class="level-item fas fa-chevron-left"></i>
                <span class="level-item">人工智能3-靠近和离开</span>
            </a>
        </div>
        
        
        <div class="level-end">
            <a class="level level-item has-link-grey  article-nav-next" href="/mystudy/2020/07/22/人工智能1-游戏AI的架构模型/">
                <span class="level-item">人工智能1-游戏AI的架构模型</span>
                <i class="level-item fas fa-chevron-right"></i>
            </a>
        </div>
        
    </div>
</div>


</div>
                




<div class="column is-4-tablet is-4-desktop is-3-widescreen  has-order-1 column-left ">
    
        
<div class="card widget">
    <div class="card-content">
        <nav class="level">
            <div class="level-item has-text-centered" style="flex-shrink: 1">
                <div>
                    
                        <img class="image is-128x128 has-mb-6" src="/mystudy/images/avatar2.jpg" alt="满头大汉老黄牛">
                    
                    
                    <p class="is-size-4 is-block">
                        满头大汉老黄牛
                    </p>
                    
                    
                    <p class="is-size-6 is-block">
                        游戏
                    </p>
                    
                    
                    <p class="is-size-6 is-flex is-flex-center has-text-grey">
                        <i class="fas fa-map-marker-alt has-mr-7"></i>
                        <span>火星</span>
                    </p>
                    
                </div>
            </div>
        </nav>
        <nav class="level is-mobile">
            <div class="level-item has-text-centered is-marginless">
                <div>
                    <p class="heading">
                        文章
                    </p>
                    <p class="title has-text-weight-normal">
                        70
                    </p>
                </div>
            </div>
            <div class="level-item has-text-centered is-marginless">
                <div>
                    <p class="heading">
                        分类
                    </p>
                    <p class="title has-text-weight-normal">
                        10
                    </p>
                </div>
            </div>
            <div class="level-item has-text-centered is-marginless">
                <div>
                    <p class="heading">
                        标签
                    </p>
                    <p class="title has-text-weight-normal">
                        3
                    </p>
                </div>
            </div>
        </nav>
        <div class="level">
            <a class="level-item button is-link is-rounded" href="https://github.com/koliy/" target="_blank">
                关注我</a>
        </div>
        
        
        <div class="level is-mobile">
            
            <a class="level-item button is-white is-marginless" target="_blank"
                title="Github" href="https://github.com/koliy/">
                
                <i class="fab fa-github"></i>
                
            </a>
            
        </div>
        
    </div>
</div>
    
        


    
        
<div class="card widget">
    <div class="card-content">
        <div class="menu">
            <h3 class="menu-label">
                分类
            </h3>
            <ul class="menu-list">
            <li>
        <a class="level is-marginless" href="/mystudy/categories/3D数学基础-图形与游戏开发/">
            <span class="level-start">
                <span class="level-item">3D数学基础:图形与游戏开发</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">3</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/mystudy/categories/AI/">
            <span class="level-start">
                <span class="level-item">AI</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">12</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/mystudy/categories/MySql/">
            <span class="level-start">
                <span class="level-item">MySql</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/mystudy/categories/SurfaceShader/">
            <span class="level-start">
                <span class="level-item">SurfaceShader</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/mystudy/categories/Unity/">
            <span class="level-start">
                <span class="level-item">Unity</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/mystudy/categories/git/">
            <span class="level-start">
                <span class="level-item">git</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">3</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/mystudy/categories/shade学习/">
            <span class="level-start">
                <span class="level-item">shade学习</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">33</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/mystudy/categories/xlua/">
            <span class="level-start">
                <span class="level-item">xlua</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/mystudy/categories/网络同步/">
            <span class="level-start">
                <span class="level-item">网络同步</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">10</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/mystudy/categories/设计模式/">
            <span class="level-start">
                <span class="level-item">设计模式</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">5</span>
            </span>
        </a></li>
            </ul>
        </div>
    </div>
</div>
    
        <div class="card widget">
    <div class="card-content">
        <div class="menu">
        <h3 class="menu-label">
            归档
        </h3>
        <ul class="menu-list">
        
        <li>
            <a class="level is-marginless" href="/mystudy/archives/2020/09/">
                <span class="level-start">
                    <span class="level-item">九月 2020</span>
                </span>
                <span class="level-end">
                    <span class="level-item tag">1</span>
                </span>
            </a>
        </li>
        
        <li>
            <a class="level is-marginless" href="/mystudy/archives/2020/07/">
                <span class="level-start">
                    <span class="level-item">七月 2020</span>
                </span>
                <span class="level-end">
                    <span class="level-item tag">23</span>
                </span>
            </a>
        </li>
        
        <li>
            <a class="level is-marginless" href="/mystudy/archives/2020/06/">
                <span class="level-start">
                    <span class="level-item">六月 2020</span>
                </span>
                <span class="level-end">
                    <span class="level-item tag">17</span>
                </span>
            </a>
        </li>
        
        <li>
            <a class="level is-marginless" href="/mystudy/archives/2020/03/">
                <span class="level-start">
                    <span class="level-item">三月 2020</span>
                </span>
                <span class="level-end">
                    <span class="level-item tag">2</span>
                </span>
            </a>
        </li>
        
        <li>
            <a class="level is-marginless" href="/mystudy/archives/2020/02/">
                <span class="level-start">
                    <span class="level-item">二月 2020</span>
                </span>
                <span class="level-end">
                    <span class="level-item tag">4</span>
                </span>
            </a>
        </li>
        
        <li>
            <a class="level is-marginless" href="/mystudy/archives/2019/09/">
                <span class="level-start">
                    <span class="level-item">九月 2019</span>
                </span>
                <span class="level-end">
                    <span class="level-item tag">5</span>
                </span>
            </a>
        </li>
        
        <li>
            <a class="level is-marginless" href="/mystudy/archives/2019/08/">
                <span class="level-start">
                    <span class="level-item">八月 2019</span>
                </span>
                <span class="level-end">
                    <span class="level-item tag">18</span>
                </span>
            </a>
        </li>
        
        </ul>
        </div>
    </div>
</div>
    
        
<div class="card widget">
    <div class="card-content">
        <h3 class="menu-label">
            标签云
        </h3>
        <a href="/mystudy/tags/game/" style="font-size: 15px;">game</a> <a href="/mystudy/tags/git/" style="font-size: 10px;">git</a> <a href="/mystudy/tags/学习/" style="font-size: 20px;">学习</a>
    </div>
</div>

    
    
        <div class="column-right-shadow is-hidden-widescreen is-sticky">
        
            
<div class="card widget" id="toc">
    <div class="card-content">
        <div class="menu">
            <h3 class="menu-label">
                目录
            </h3>
            <ul class="menu-list"><li>
        <a class="is-flex" href="#操纵行为">
        <span class="has-mr-6">1</span>
        <span>操纵行为</span>
        </a></li><li>
        <a class="is-flex" href="#主要基类">
        <span class="has-mr-6">2</span>
        <span>主要基类</span>
        </a><ul class="menu-list"><li>
        <a class="is-flex" href="#将AI角色抽象为一个质点-Vehicle类">
        <span class="has-mr-6">2.1</span>
        <span>将AI角色抽象为一个质点-Vehicle类</span>
        </a></li><li>
        <a class="is-flex" href="#各种操控行为的基类-Vehicle类">
        <span class="has-mr-6">2.2</span>
        <span>各种操控行为的基类-Vehicle类</span>
        </a></li><li>
        <a class="is-flex" href="#控制AI角色移动-AILocomotion">
        <span class="has-mr-6">2.3</span>
        <span>控制AI角色移动-AILocomotion</span>
        </a></li></ul></li></ul>
        </div>
    </div>
</div>

        
        </div>
    
</div>

                




<div class="column is-4-tablet is-4-desktop is-3-widescreen is-hidden-touch is-hidden-desktop-only has-order-3 column-right is-sticky">
    
        
<div class="card widget" id="toc">
    <div class="card-content">
        <div class="menu">
            <h3 class="menu-label">
                目录
            </h3>
            <ul class="menu-list"><li>
        <a class="is-flex" href="#操纵行为">
        <span class="has-mr-6">1</span>
        <span>操纵行为</span>
        </a></li><li>
        <a class="is-flex" href="#主要基类">
        <span class="has-mr-6">2</span>
        <span>主要基类</span>
        </a><ul class="menu-list"><li>
        <a class="is-flex" href="#将AI角色抽象为一个质点-Vehicle类">
        <span class="has-mr-6">2.1</span>
        <span>将AI角色抽象为一个质点-Vehicle类</span>
        </a></li><li>
        <a class="is-flex" href="#各种操控行为的基类-Vehicle类">
        <span class="has-mr-6">2.2</span>
        <span>各种操控行为的基类-Vehicle类</span>
        </a></li><li>
        <a class="is-flex" href="#控制AI角色移动-AILocomotion">
        <span class="has-mr-6">2.3</span>
        <span>控制AI角色移动-AILocomotion</span>
        </a></li></ul></li></ul>
        </div>
    </div>
</div>

    
    
</div>

            </div>
        </div>
    </section>
    <footer class="footer">
    <div class="container1">
        <div class="level1">
            <div class="level-start1 has-text-centered-mobile1">
                <a class="footer-logo is-block has-mb-6" href="/mystudy/">
                

                
                </a>
                <p class="is-size-7">
                &copy; 2020 Koliy&nbsp;
                Powered by <a href="https://github.com/koliy/koliy.github.io" target="_blank">Hexo</a> & <a
                        href="https://github.com/ppoffice/hexo-theme-icarus" target="_blank">Icarus</a>
                
                <br>
                <span id="busuanzi_container_site_uv">
                共<span id="busuanzi_value_site_uv">0</span>个访客
                </span>
                
                </p>
            </div>
            <div class="level-end1">
            
            </div>
        </div>
    </div>
</footer>
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/moment@2.22.2/min/moment-with-locales.min.js"></script>
<script>moment.locale("zh-CN");</script>

<script>
var IcarusThemeSettings = {
    article: {
        highlight: {
            clipboard: true,
            fold: 'unfolded'
        }
    }
};
</script>


    <script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.4/dist/clipboard.min.js" defer></script>



    
    
    
    <script src="/mystudy/js/animation.js"></script>
    

    
    
    
    <script src="https://cdn.jsdelivr.net/npm/lightgallery@1.6.8/dist/js/lightgallery.min.js" defer></script>
    <script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js" defer></script>
    <script src="/mystudy/js/gallery.js" defer></script>
    

    
    

<div id="outdated">
    <h6>Your browser is out-of-date!</h6>
    <p>Update your browser to view this website correctly. <a id="btnUpdateBrowser" href="http://outdatedbrowser.com/">Update
            my browser now </a></p>
    <p class="last"><a href="#" id="btnCloseUpdateBrowser" title="Close">&times;</a></p>
</div>
<script src="https://cdn.jsdelivr.net/npm/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.js" defer></script>
<script>
    document.addEventListener("DOMContentLoaded", function () {
        outdatedBrowser({
            bgColor: '#f25648',
            color: '#ffffff',
            lowerThan: 'flex'
        });
    });
</script>


    
    
<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.5/unpacked/MathJax.js?config=TeX-MML-AM_CHTML" defer></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
    MathJax.Hub.Config({
        'HTML-CSS': {
            matchFontHeight: false
        },
        SVG: {
            matchFontHeight: false
        },
        CommonHTML: {
            matchFontHeight: false
        },
        tex2jax: {
            inlineMath: [
                ['$','$'],
                ['\\(','\\)']
            ]
        }
    });
});
</script>

    
    

<a id="back-to-top" title="回到顶端" href="javascript:;">
    <i class="fas fa-chevron-up"></i>
</a>
<script src="/mystudy/js/back-to-top.js" defer></script>


    
    

    
    
    
    

    
    
    
    
    

    


<script src="/mystudy/js/main.js" defer></script>

    
    <div class="searchbox ins-search">
    <div class="searchbox-container ins-search-container">
        <div class="searchbox-input-wrapper">
            <input type="text" class="searchbox-input ins-search-input" placeholder="想要查找什么..." />
            <span class="searchbox-close ins-close ins-selectable"><i class="fa fa-times-circle"></i></span>
        </div>
        <div class="searchbox-result-wrapper ins-section-wrapper">
            <div class="ins-section-container"></div>
        </div>
    </div>
</div>
<script>
    (function (window) {
        var INSIGHT_CONFIG = {
            TRANSLATION: {
                POSTS: '文章',
                PAGES: '页面',
                CATEGORIES: '分类',
                TAGS: '标签',
                UNTITLED: '(无标题)',
            },
            CONTENT_URL: '/mystudy/content.json',
        };
        window.INSIGHT_CONFIG = INSIGHT_CONFIG;
    })(window);
</script>
<script src="/mystudy/js/insight.js" defer></script>
<link rel="stylesheet" href="/mystudy/css/search.css">
<link rel="stylesheet" href="/mystudy/css/insight.css"><!-- hexo-inject:begin --><!-- Begin: Injected MathJax -->
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({"tex2jax":{"inlineMath":[["$","$"],["\\(","\\)"]],"skipTags":["script","noscript","style","textarea","pre","code"],"processEscapes":true},"TeX":{"equationNumbers":{"autoNumber":"AMS"}}});
</script>

<script type="text/x-mathjax-config">
  MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
      all[i].SourceElement().parentNode.className += ' has-jax';
    }
  });
</script>

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js">
</script>
<!-- End: Injected MathJax -->
<!-- hexo-inject:end -->
    
</body>
</html>